package org.kl.auditsupervision.service.fnd;

import java.util.ArrayList;
import java.util.List;

import org.kl.auditsupervision.dto.audit.CompletionRateStatistic;
import org.kl.auditsupervision.dto.audit.InControlTypeStatistic;
import org.kl.auditsupervision.dto.audit.ProSeverityStatistic;
import org.kl.auditsupervision.dto.audit.QueTypeStatistic;
import org.kl.auditsupervision.dto.audit.RecEffectStatistic;
import org.kl.auditsupervision.entity.fnd.AuditPro;
import org.kl.auditsupervision.entity.fnd.AuditProNop;
import org.kl.auditsupervision.repository.fnd.AuditProDao;
import org.kl.auditsupervision.repository.fnd.CompletionRateStatisticDao;
import org.kl.auditsupervision.repository.fnd.InControlTypeStatisticDao;
import org.kl.auditsupervision.repository.fnd.ProSeverityStatisticDao;
import org.kl.auditsupervision.repository.fnd.QueTypeStatisticDao;
import org.kl.auditsupervision.repository.fnd.RecEffectStatisticDao;
import org.kl.bf.service.BasicService;
import org.kl.bf.utils.CommonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;


/**
 * 
 * 审计表
 * @author LJ
 *
 */
@Component
//默认将类中的所有public函数纳入事务管理.
@Transactional
public class AuditProService extends BasicService<AuditPro>
{
  @Autowired
  private AuditProDao auditProDao;
  @Autowired
  private RecEffectStatisticDao recEffectStatisticDao;
  @Autowired
  private QueTypeStatisticDao queTypeStatisticDao;
  @Autowired
  private ProSeverityStatisticDao proSeverityStatisticDao;
  @Autowired
  private InControlTypeStatisticDao inControlTypeStatisticDao;
  @Autowired
  private CompletionRateStatisticDao completionRateStatisticDao;
  
  
  
  public List<AuditPro> findByAuditName(String auditName){
	  return auditProDao.findByAuditName(auditName);
  }
  
  
  public List<RecEffectStatistic> getRecEffectStatistic(String startYear,String endYear,String type,int pageNumber,int pageSize,String sortType,String orderType) {
		List<RecEffectStatistic> result = new ArrayList<>();
		sortType=CommonUtil.formatSqlColumn(sortType,"");
		result=recEffectStatisticDao.getRecEffectStatistic(startYear,endYear,type,pageNumber,pageSize,sortType,orderType);
		return result;
	}
	
	public int getRecEffectStatisticCount(String startYear,String endYear,String type) {
		int count=0;
		count=recEffectStatisticDao.getRiskDimensionStatisticCount(startYear,endYear,type);
		return count;
	}
	
	public List<QueTypeStatistic> getQueTypeStatistic(String startYear,String endYear,String type,int pageNumber,int pageSize,String sortType,String orderType) {
		List<QueTypeStatistic> result = new ArrayList<>();
		sortType=CommonUtil.formatSqlColumn(sortType,"");
		result=queTypeStatisticDao.getQueTypeStatistic(startYear,endYear,type,pageNumber,pageSize,sortType,orderType);
		return result;
	}
	
	public int getQueTypeStatisticCount(String startYear,String endYear,String type) {
		int count=0;
		count=queTypeStatisticDao.getQueTypeStatisticCount(startYear,endYear,type);
		return count;
	}
	
	public List<ProSeverityStatistic> getProSeverityStatistic(String startYear,String endYear,String type,int pageNumber,int pageSize,String sortType,String orderType) {
		List<ProSeverityStatistic> result = new ArrayList<>();
		sortType=CommonUtil.formatSqlColumn(sortType,"");
		result=proSeverityStatisticDao.getProSeverityStatistic(startYear,endYear,type,pageNumber,pageSize,sortType,orderType);
		return result;
	}
	
	public int getProSeverityStatisticCount(String startYear,String endYear,String type) {
		int count=0;
		count=proSeverityStatisticDao.getProSeverityStatisticCount(startYear,endYear,type);
		return count;
	}
	
	public List<InControlTypeStatistic> getInControlTypeStatistic(String startYear,String endYear,String type,int pageNumber,int pageSize,String sortType,String orderType) {
		List<InControlTypeStatistic> result = new ArrayList<>();
		sortType=CommonUtil.formatSqlColumn(sortType,"");
		result=inControlTypeStatisticDao.getInControlTypeStatistic(startYear,endYear,type,pageNumber,pageSize,sortType,orderType);
		return result;
	}
	
	public int getInControlTypeStatisticCount(String startYear,String endYear,String type) {
		int count=0;
		count=inControlTypeStatisticDao.getInControlTypeStatisticCount(startYear,endYear,type);
		return count;
	}
	
	public List<CompletionRateStatistic> getCompletionRateStatistic(String startDate,String endDate,String type,String orgId,int pageNumber,int pageSize,String sortType,String orderType) {
		List<CompletionRateStatistic> result = new ArrayList<>();
		sortType=CommonUtil.formatSqlColumn(sortType,"");
		result=completionRateStatisticDao.getCompletionRateStatistic(startDate,endDate,type,orgId,pageNumber,pageSize,sortType,orderType);
		return result;
	}
	
	public int getCompletionRateStatisticCount(String startYear,String endYear,String type,String orgId) {
		int count=0;
		count=completionRateStatisticDao.getCompletionRateStatisticCount(startYear,endYear,type,orgId);
		return count;
	}
}
